package 数组;

import java.util.Arrays;

/**
 * @Author Weton Li
 * @Date 2021/5/1 10:17
 */
public class 数组拆分 {
    public static void main(String[] args) {
        int[] input = {6,2,6,5,1,2};
        System.out.println(method(input));

    }

    public static int method(int[] arr){
        Arrays.sort(arr);
        int i =0;
        int res = 0;
        int n = arr.length;
        while(i<n-1){
            res+=arr[i];
            i+=2;
        }
        return res;
    }
}
